<template>
	<view class="wap">
		<view class="back-container">
			<image class="back-img" src="@/static/img/mine-header-bg.png">
			</image>
		</view>
		<view class="base-container container" style="margin-top: 0;padding-top: 9px;">
			<view class="item flex-y-center">
				<view class="left">
					<image class="head-img"
						:src="info.avatar">
					</image>
				</view>
				<view class="right">
					<text class="nickname">{{info.nickname}}</text>
				</view>
			</view>
		</view>
		<view class="team-container container">

			<view class="item">
				<view class="left half">
					<text class="grey-text">店铺数量（个）</text>
				</view>
				<view class="right half">
					<text class="grey-text">累计为您增长（单）</text>
				</view>
			</view>
			<view class="item">
				<view class="left half">
					<text class="amount">{{store_count}}</text>
				</view>
				<view class="right half">
					<text class="amount">{{order_count}}</text>
				</view>
			</view>
			<view class="item">
				<view class="left half">
					<text class="grey-text">待结算金额（元）</text>
				</view>
				<view class="right half">
					<text class="grey-text">已结算金额（元）</text>
				</view>
			</view>
			<view class="item">
				<view class="left half">
					<text class="amount">{{not_pay}}</text>
				</view>
				<view class="right half">
					<text class="amount">{{had_pay}}</text>
				</view>
			</view>
		</view>
		<view class="menu-container container">
	
			<navigator url="/pages/settlement/settlement" class="item">
				<view class="left">
					<image class="menu-icon" src="@/static/img/mine-bug-feedback.png">

					</image>
					<view class="menu-title">结算店铺</view>
				</view>
				<view class="right">
					<image src="@/static/img/right.png" style="width: 35rpx;height: 35rpx;"></image>
				</view>
			</navigator>
			<navigator url="/pages/store/store" class="item">
				<view class="left">
					<image class="menu-icon" src="@/static/img/mine-seller.png">
					</image>
					<view class="menu-title">我的店铺</view>
				</view>
				<view class="right">
					<image src="@/static/img/right.png" style="width: 35rpx;height: 35rpx;"></image>
				</view>
			</navigator>
			<view class="item" @click="logout">
				<view class="left">
					<image class="menu-icon" src="@/static/img/mine-exit.png">
					</image>
					<view class="menu-title">退出登录</view>
				</view>
				<view class="right">
					<image src="@/static/img/right.png" style="width: 35rpx;height: 35rpx;"></image>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getUserIndex,
		logout
	} from '../../apirequest/api.js';
	export default {
		data() {
			return {
				info: [],
				store_count:0,
				order_count:0,
				not_pay:'0.00',
				had_pay:'0.00',
			}
		},
		onShow: function() {
			this.loadData();
		},
		methods: {
			record(e) {
				uni.navigateTo({
					url: '/pages/revenueRecord/revenueRecord'
				})
			},
			//退出登录
			logout: function() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗?',
					success(ret) {
						if (ret.confirm) {
							logout({}).then((res) => {
								if (res.code == 1) {
									uni.showToast({
										title: res.msg,
										icon: 'success'
									});
									setTimeout(function() {
										uni.setStorageSync('token', '');
										uni.navigateTo({
											url: '/pages/wechatLogin/wechatLogin'
										})
									}, 1000);
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'error'
									})
								}
							})
						}
						if (ret.cancel) {

						}
					}
				});
			},
			//获取数据
			loadData: function() {
				getUserIndex({}).then((res) => {
					if (res.code == 1) {
						this.info = res.data.info;
						this.store_count = res.data.store_count;
						this.order_count = res.data.order_count;
						this.not_pay = res.data.not_pay;
						this.had_pay = res.data.had_pay;
					} else {
						uni.showToast({
							title: res.msg,
							icon: "error"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta: 0
							});
						}, 1000)
					}
				}).catch(err => {
					console.log(err)
				})

			},
			record(e) {
				uni.navigateTo({
					url: '/pages/revenueRecord/revenueRecord'
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #f7f8f9;
	}

	.uni-icons {
		font-family: uniicons;
		text-decoration: none;
		text-align: center;
	}

	.wap .container {
		margin: 9px 14px 0 14px;
		padding: 4px 7px;
		border-radius: 9px;
		background-color: #fff;
		position: relative;
	}

	.wap .container .item {
		padding: 4px 0;
		display: flex;
		justify-content: space-between;
	}

	.wap .back-container {
		position: absolute;
		width: 100%
	}

	.wap .back-container .back-img {
		height: 144px;
		width: 100%
	}

	.wap .base-container {
		background-color: unset;
		padding: 0
	}

	.wap .base-container .item {
		justify-content: flex-start
	}

	.wap .base-container .item .left .head-img {
		width: 61px;
		height: 61px;
		border-radius: 50%
	}
	.wap .base-container .item .right {
		display: flex;
		flex-flow: column;
		margin-left: 7px
	}

	.wap .base-container .item .right .nickname {
		color: #333;
		    font-size: 36rpx;;

	}

	.wap .team-container {
		padding: 4px 0
			/* 我的资产 */
	}

	.wap .team-container .item {
		margin: 0 7px
	}


	.wap .team-container .item .half .amount{
		font-weight: 700;
		font-size: 34rpx;
	}
	.wap .team-container .item .half {
		width: 50%
	}

	.wap .team-container .item .right {
		display: flex
	}

	.wap .menu-container {
		margin-bottom: 9px
	}

	.wap .menu-container .item {
		padding: 30rpx 0
	}
	.wap .menu-container .item .left {
		display: flex
	}

	.wap .menu-container .item .left .menu-icon {
		width: 19px;
		height: 19px
	}

	.wap .menu-container .item .left .menu-title {
		    font-size: 28rpx;;
		font-weight: 600;
		margin-left: 7px
	}

	.wap .menu-container .item .right {
		display: flex
	}

	.wap .menu-container .item .right .menu-desc {
		color: #bec1c7;
		font-size: 26rpx;
	}

	.wap .menu-container .item .right .menu-share-desc {
		color: #eb2622;
		    font-size: 28rpx;;
		font-weight: 700
	}

	.wap .grey-text {
		color: #bec1c7;
		font-size: 12px;
	}
</style>
